SwapIt / app / api / users / [id] / posts / route.js
route.js
Raw
import { op } from "@utils/user.mjs";

export const GET = async (req, {params}) => {

    try {
        const Products_Detail = await op.ReadProduct();
        const Posted_Products = [];
        Products_Detail.slice(1).map((product) => {
            if(product[1] == params.id){
                Posted_Products.push(product)
            }
        })
        return new Response(JSON.stringify(Posted_Products) , {status:200})
        
    } catch (error) {
        return new Response("Failed to read the Products" , {status:500});
    }
}